<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<title>Gimme Get and Set HTML and Value Tests</title>

		<script type = "text/javascript" src = "../jsunit/app/jsUnitCore.js"></script>
		<script type = "text/javascript" src = "../utils/jsunit/jsUnitHelperFunctions.js"></script>
		<script type = "text/javascript" src = "../build/debug/gimme.js"></script>
		
		<script type = "text/javascript">
			var pageHTML;
			function setUpPage()
			{
				pageHTML = document.body.innerHTML;
				setUpPageStatus = 'complete';
			}
			function setUp()
			{
				document.body.innerHTML = pageHTML;				
			}
			
			function test_get_htmlOfIvyPlant1()
			{
				// cross-browser difference in .innerHTML make this difficult to test accurately, so rather than trying to ensure an exact match,
				// we simply verify the existence of some keywords to indicate that the innerHTML was successfully retrieved.
				var html = g('#ivyPlant1').get_html();
				assertTrue('html was not correctly retrieved.', html.indexOf('foo') !== -1 && html.indexOf('Poison Ivy Plant 1') !== -1);
			}
			
			function test_set_htmlOfAllDivs()
			{
				// cross-browser difference in .innerHTML make this difficult to test accurately, so rather than trying to ensure an exact match,
				// we simply verify the existence of some keywords to indicate that the innerHTML was successfully set.			
				var gObj = g('div').set_html('<span class="yippie doo">YippieDoo!</span>');
				gObj.for_each(function(el)
				{
					var html = el.innerHTML;
					assertTrue('html was not correctly set.', html.indexOf('yippie') !== -1 && html.indexOf('Doo!') !== -1 && html.indexOf('Panda') === -1);
				});
			}
			
			function test_get_valOfTxtFirstName()
			{
				var val = g('#TxtFirstName').get_val();
				assertEquals('values are not equal.', 'Stephen', val);
			}
			
			function test_tryValueOfNonFormElement()
			{
				var val = g('div').get_val();
				assertEquals('values are not equal.', '', val);
			}
			
			function test_set_valOfAllInputs()
			{
				var gObj = g('input').set_val('Steve Rocks!');
				gObj.for_each(function(el)
				{
					assertEquals('values are not equasl.', 'Steve Rocks!', el.value);
				});
			}			
		</script>
	</head>

	<body>
		<h1>Gimme Get and Set HTML and Value Tests</h1>

		<div id = "zoo" class = "place man-made">
			<span id = "panda1" class = "panda">Panda1</span>
			<span id = "tiger1" class = "tiger">Tiger1</span>
			<span id = "panda2" class = "panda">Panda2</span>
			<span id = "panda3" class = "panda" foo = "bar">Panda3</span>
		</div>
		<div id = "forest" class = "place natural">
			<p id = "tree1" class = "tree pine">Pine tree 1</p>
			<p id = "tree2" class = "tree oak">Oak tree 1</p>
			<span id = "chipmunk1" class = "mammal chipmunk">Chipmunk 1</span>
			<span id = "gazelle1" class = "mammal gazelle">Gazelle 1</span>
			<p id = "ivyPlant1" class = "ivy poison"><b class = "foo">Poison Ivy Plant 1</b></p>
			<input id = "TxtFirstName" value = "Stephen" />
			<input id = "TxtLastName" value = "Stchur" />
		</div>
	</body>

</html>